//
//  detailIntroduction.m
//  HuiPinZhiJia
//
//  Created by MS on 16/8/31.
//  Copyright © 2016年 MS. All rights reserved.
//

#import "detailIntroduction.h"

@interface detailIntroduction ()
@property (nonatomic,strong)UIView *view1;
@property (nonatomic,strong)UIView *view2;
@end

@implementation detailIntroduction

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"详细描述";
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.view1];
    [self addPage];
    // Do any additional setup after loading the view.
}
#pragma mark 界面切换
- (void)addPage
{
    for (int i = 0; i < 2; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(0 + screenWidth/2*i+1, 69, screenWidth/2, 60);
        [btn setTitleColor:[UIColor colorWithRed:0.73 green:0.84 blue:0.89 alpha:1.00] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor colorWithRed:0.33 green:0.67 blue:0.87 alpha:1.00] forState:UIControlStateSelected];
        btn.titleLabel.font = [UIFont systemFontOfSize:20];
        btn.tag = 1000+i;
        [btn addTarget:self action:@selector(responseSegmentedControl:) forControlEvents:UIControlEventTouchUpInside];
        [btn.layer setBorderWidth:0.5];
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0.92, 0.92,  0.92,  1.00});
        [btn.layer setBorderColor:colorref];
        [self.view addSubview:btn];
        if (i == 0) {
            [btn setTitle:@"商品描述" forState:UIControlStateNormal];
            btn.selected = YES;
        }else{
            [btn setTitle:@"商品属性" forState:UIControlStateNormal];
        }
    }
    
}

- (void)responseSegmentedControl:(UIButton *)segment
{
    if (segment.tag == 1000)
    {
        [self.view addSubview:self.view1];
        UIButton *btn = [self.view viewWithTag:1001];
        btn.selected = NO;
        segment.selected = YES;
    }else
    {
        [self.view addSubview:self.view2];
        UIButton *btn = [self.view viewWithTag:1000];
        btn.selected = NO;
        segment.selected = YES;
    }
}

- (UIView *)view1
{
    if (!_view1)
    {
        _view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 130, screenWidth, screenHeight - 130)];
        _view1.backgroundColor = [UIColor redColor];
    }
    return _view1;
}

- (UIView *)view2
{
    if (!_view2)
    {
        _view2 = [[UIView alloc]initWithFrame:CGRectMake(0, 130, screenWidth, screenHeight- 130)];
        _view2.backgroundColor = [UIColor yellowColor];
    }
    return _view2;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
